#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 19-6-2 上午11:05
# @Author  : Jason
# @Site    : 
# @File    : __init__.py.py
# @Software: PyCharm
from flask import Blueprint
# 创建蓝图对象
from flask import redirect
from flask import request
from flask import session
from flask import url_for

admin_blu =Blueprint('admin',__name__)

from . import views

@admin_blu.before_request
def check_admin():
    # if 不是管理员那么直接跳到主页
    is_admin =session.get('is_admin',False)
    if not is_admin and not request.url.endswith(url_for('admin.login')):
        return  redirect('/')